package com.educate.controller;

import com.educate.common.api.Result;
import com.educate.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * @author yjj
 * @date 2021/11/22
 * @description: 课程Controller(student)
 */
@Api(tags = "学生课程接口")
@RestController
@RequestMapping("course/stu")
public class StuCourseController {

    @Autowired
    private CourseService courseService;

    /**
     * 学生根据classId加入对应课程
     * @param classId
     */
    @ApiOperation("加入课程")
    @PreAuthorize("hasAuthority('sys:stu')")
    @GetMapping("/join")
    public Result joinClassId(@ApiParam(value = "课程id",required = true) @RequestParam("classId") String classId){
        courseService.studentBindClass(classId);
        return Result.success("加入班级成功！");
    }

    /**
     * 获取我的课程(学生)
     * @return List<CourseTypeDto>
     */
    @ApiOperation("获取我的课程(学生)")
    @GetMapping("/myCourse")
    public Result getAllOnlineCourse(){
        return Result.success(courseService.getStuCourse());
    }

}
